package com.rainxing.cockpit.modules.login;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Auther: ybzhu
 * @Date: 2018/10/25 17:25
 * @Mail: 110668032@qq.com
 * @Description:
 */
@Controller
public class LoginController {

    @ApiIgnore//使用该注解忽略这个API
    public HttpSession getSession() {
        //获取到ServletRequestAttributes 里面有
        ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        //获取到Request对象
        HttpServletRequest request = attrs.getRequest();
        //获取到Session对象
        HttpSession session = request.getSession();
        //获取到Response对象
        //HttpServletResponse response = attrs.getResponse();
        return session;
    }

    @ApiIgnore//使用该注解忽略这个API
    @RequestMapping("/cockpit")
    public String htm() {
        return "cockpit";
    }

    @ApiIgnore//使用该注解忽略这个API
    @RequestMapping("/html/clickmap")
    public String street(String street) {
        HttpSession session = getSession();
        return "html/clickmap";
    }

}
